package com.ag.wzp.bak;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ag.bean.TbEvent;
import com.ag.bean.TbPropose;
import com.ag.bean.TbUser;
import com.ag.common.BaseAction;
import com.ag.common.IPermissionService;
import com.ag.wzp.service.impl.EventServiceImpl;
/**
 * 呈批
 * @author 温镇澎
 *
 */
@Scope("prototype")
@Controller("proposeAction")
public class ProposeAction extends BaseAction implements SessionAware{
	private static final long serialVersionUID = 1L;
	private static final Logger logger = Logger.getLogger(ProposeAction.class);
	
	/**
	 * 调用权限服务逻辑组件
	 */
	@Resource(name = "PermissionServiceImpl")
	private IPermissionService pms;
	/**
	 * 提供Map<String, Object>类型的Session变量，用来保存Struts2注入的Session上下文
	 */
	private Map<String, Object> sessionMap;
	@Override
	public void setSession(Map<String, Object> session) {
		this.sessionMap = session;
	}
	@Resource(name="proposeServiceImpl")
	private ProposeServiceImpl proposeServiceImpl;
	@Resource(name="eventServiceImpl")
	private EventServiceImpl eventServiceImpl;
	private TbPropose propose;
	private String tbesId;
	
	public void save(){
		TbUser user = pms.getCurrentUser(sessionMap);
		logger.info(tbesId);
		logger.info(user.getUId());
		//propose.setTbUserByUId(user);
		this.proposeServiceImpl.save(propose);
		String EId = propose.getTbEvent().getEId();
		this.eventServiceImpl.update(EId,tbesId);
		this.outJsonString("呈批成功！");
	}
	
	public TbPropose getPropose() {
		return propose;
	}

	public void setPropose(TbPropose propose) {
		this.propose = propose;
	}

	public String getTbesId() {
		return tbesId;
	}

	public void setTbesId(String tbesId) {
		this.tbesId = tbesId;
	}

}
